<%@ page contentType="text/html;charset=UTF-8"%>
<script type="text/javascript">
	//是否服务器分页
	var _isServerPage = true;
	//表格列定义
	var _tableCols = 	[{
		data : "uuid",
		sortable : false,
		className : "center",
		width : "30",
		render : RapDataTableUtils.renderCheckCol
	},
	{
		data : 'quitDate',
		width : "120",
		//render : function(data, type, full){},
		sortable : true
	},
	{
		data : 'contract.contractNum',
		width : "120",
		render : function(data, type, full){
			return "<a href='#' onclick='onViewContract(this,\""+full.contract.uuid+"\");'>"+data+"</a>";
		},
		sortable : true
	},
	{
		data : 'contract.custom.theName',
		width : "120",
		//render : function(data, type, full){},
		sortable : true
	},
	{
		data : 'history',
		width : "120",
		className:"rap-td-number",
		render:milliFormat,
		sortable : true
	},
	{
		data : 'deposit',
		width : "120",
		className:"rap-td-number",
		render:milliFormat,
		sortable : true
	},
	{
		data : 'isReturn',
		width : "120",
		render : function(data, type, full){
			return RapDataUtils.getEnumName("BooleanType", data);
		},
		sortable : true
	},
	{
		data : 'remark',
		width : "220",
		render : function(data, type, full){
			return RapDataTableUtils.renderStrByLength(data,28);
		},
		sortable : true
	}/* ,
	{
		data : "uuid",
		className : "center",
		sortable : false,
		render : RapDataTableUtils.renderActionCol,
		width : "80"
	} */]
;
	function onViewContract(obj,uuid){
		$(obj).colorbox({
			iframe:true,
			opacity	: 0.2,
			overlayClose:true, 
			transition : 'none',
			speed : 200,
			href : "${ctx}/lease/contract/view?uuid="+uuid,
			innerWidth : '90%',
			innerHeight : '85%',
			close : '×',
			fixed : true
		});
	}
	//宏：生成ShowData方法，在编辑框显示记录数据
	function showData(data) {
		$("input[name='uuid']").val(data.uuid);
		$("input[name='quitDate']").val(data.quitDate);
		$("input[name='contract.contractNum']").val(data.contract.contractNum);
		$("input[name='history']").val(data.history);
		$("input[name='deposit']").val(data.deposit);
		$("textarea[name='remark']").val(data.remark);
	}
	function bindOtherActions(){
		$("#rap-btn-return").bind("click",function(){
			doReturnMoney();
		});
	}
	$(document).ready(function() {
		bindDefaultActions();
		bindOtherActions();
		if(_isServerPage){
			//服务器分页
			serverPage();	
		}else{
			//非服务器分页
			_tableList = $('#rap-table-list').DataTable({
				"columns" : _tableCols,
				"createdRow" : RapDataTableUtils.setActions,
				"order": [] 
			});
			loadList();		
		}
		
		RapDataTableUtils.setCheckCol(_tableList);

		/**
		 * 表单校验
		 */
		_validator = $('#rap-form-edit').validate({
					rules : {
						quitDate : {
							required : true
						},
						uuid : {
							required : true
						}
					},
					messages : {
					}
				});
	});
</script>